<template>
	<view>
		<wx-open-launch-app id="launch-btn" ref="launchBtn" appid="wx14a15d2c7b15c79f" :extinfo="extinfo"
			class="launchbtn"
			style="position: fixed;bottom: 10px;left: 50%;transform: translateX(-50%);width:350px;z-index: 100;">
			<script type="text/wxtag-template">
				<view class="goApp" style="background:rgba(0,0,0,0.7);display:flex;justify-content:space-between;align-items:center;box-size:border-box;padding:6px;border-radius:5px">
						<view class="logo" style="border-radius:5px">
							<image style="width:45px;height:45px;border-radius:5px;" src="https://oss.cardplayd.com/cardplay/common/config/app_logo.png" mode=""></image>
						</view>
						<view class="description" style="display:block;padding-right:68px;color:#ffffff;">
							<view class="descriptionTitle" style="display:block">卡玩</view>
							<view style="font-size: 14px;display:block">前往 APP 查看详情</view>
						</view>
						<view class="btnGoApp" style="display:block;width:90px;height:35px;line-height:35px;font-size:15px;text-align:center;background-color:rgb(39, 232, 39);border-radius:6px;font-weight:bold;">
							立即前往
						</view>
					</view> 
			  </script>
		</wx-open-launch-app>
		<view v-if="!weixinFlag&&isIos" class="goApp" @click="goApp">
			<view class="logo">
				<image src="https://oss.cardplayd.com/cardplay/common/config/app_logo.png" mode=""></image>
			</view>
			<view class="description">
				<view class="descriptionTitle">卡玩</view>
				<view style="font-size: 28rpx;">前往 APP 查看详情</view>
			</view>
			<view class="btnGoApp">
				立即前往
			</view>
		</view>
	</view>
</template>

<script>
	import openInWechat from '@/mixins/openInWechat.js'
	export default {
		name: 'sys-weixin',
		mixins: [openInWechat],
		props: {
			router: {
				type: String,
				default: '',
			},
			string:{
				type:String,
				default:' 查看详情',
			},
			isboser:{
				type:Boolean,
				default:false,
			}
		},
		watch: {
			router: {
				handler: function() {
					if (this.router) {
						this.extinfo = `https://help.cardplayd.com/${this.router}`
						this.getSystemInfo()
					}
				},
				deep: true,
				immediate: true,
			}
		},
		data() {
			return {
				extinfo: '',
			}
		},
		methods: {
			goApp() {
				// alert(this.ua)
				if (this.ua.indexOf('Weixin') !== -1 || this.ua.indexOf('WeChat') !== -1) {
					this.show = true
					return false
				}
				this.watchVisibility()
				this.timer = setTimeout(() => {
					uni.reLaunch({
						url: '/pages/webMobile/webMobile'
					})
				}, 5000)
				if (this.osName == "ios") { //ios系统的处理
					window.location.href =
						`https://help.cardplayd.com/${this.router}`
				} else if (this.osName == "android") { //Android系统的处理
					if(this.isboser){
						window.location.href =
							`kawan://help.cardplayd.com`
					}else{
						window.location.href =
							`kawan://help.cardplayd.com/${this.router}`
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goApp {
		width: 710rpx;
		background-color: rgba(0, 0, 0, .7);
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: fixed;
		bottom: 20rpx;
		border-radius: 12rpx;
		overflow: hidden;
		padding: 12rpx;
		left: 50%;
		transform: translateX(-50%);
		z-index: 100;

		.logo {
			width: 90rpx;
			height: 90rpx;
			border-radius: 12rpx;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;

			}
		}

		.description {
			padding-right: 136rpx;
			color: #FFFFFF;

			letter-spacing: 1rpx;
			font-size: 30rpx;

			.descriptionTitle {
				font-weight: bolder;
				margin-bottom: 4rpx;
			}
		}

		.btnGoApp {
			width: 180rpx;
			height: 70rpx;
			line-height: 70rpx;
			font-size: 30rpx;
			text-align: center;
			// background-color: rgb(190, 253, 0);
			background-color:rgb(39, 232, 39);
			border-radius: 12rpx;
			color: #3E3E3E;
			font-weight: bold;
			letter-spacing: 1rpx;
		}
	}
</style>